package com.net.oil.message.util;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

import com.google.gson.Gson;
import com.net.oil.action.ActionDetailActivity;
import com.net.oil.app.Constant;
import com.net.oil.coupon.CouponActivity;
import com.net.oil.order.ReserveDetailActivity;
import com.net.oil.push.PushHandleActivity;
import com.net.oil.push.bean.PushBean;

/**
 * 作者：lch
 * 时间：2018/5/19 0019:上午 10:06
 * 邮箱：245850413@qq.com
 * 说明：消息列表页面，根据消息类型跳转到对应的页面
 */

public class MessageHandle {


    //注，方法后期可以优化，现在直接调用push的处理方式处理

    /**
     * 1：(展示型)，2：(活动类型)，3：(新闻类型)，4：(技术支援类型)， 5（纯文本推送，点击不做跳转处理），6预约，7优惠券
     * @param type  类型
     * @param id 对应类型的id
     */
    public static void handleMessage(Context context, int type, String id){
        Gson gson = new Gson();
        PushBean pushBean = new PushBean();
        pushBean.setNotificationType(String.valueOf(type));
        pushBean.setNotificationBusiId(id);
        if (!TextUtils.isEmpty(id)){
            switch (type){
                case 1:
                    break;
                case 2:
                    Intent intent3 = new Intent(context, ActionDetailActivity.class);
                    intent3.putExtra(Constant.INTENT_ACTION_KEY, Integer.parseInt(id));
                    context.startActivity(intent3);
                    break;
                case 3:
                    Intent intent1 = new Intent(context, PushHandleActivity.class);
                    intent1.putExtra(Constant.INTENT_PUSH_JSON, gson.toJson(pushBean));
                    context.startActivity(intent1);
                    break;
                case 4:
                    Intent intent2 = new Intent(context, PushHandleActivity.class);
                    intent2.putExtra(Constant.INTENT_PUSH_JSON, gson.toJson(pushBean));
                    context.startActivity(intent2);
                    break;
                case 5:
                    break;
                case 6:
                    Intent intent = new Intent(context, ReserveDetailActivity.class);
                    intent.putExtra(Constant.INTENT_RESERVE_ID_KEY, Integer.parseInt(pushBean.getNotificationBusiId()));
                    context.startActivity(intent);
                    break;
                case 7:
                    context.startActivity(new Intent(context, CouponActivity.class));
                    break;

            }
        }

    }
}
